async function success(res, message, data, code = 200) {
    console.log(data);
    if (data) {
        res.status(code).json({
            data: data || data.rows,
            message: message,
            count: data.count
        })
    } else {
        res.status(404).json({
            message: "未找到",
        })
    }
}

function fail(res, message, code = 404) {
    res.status(code).json({
        message: message,
    })
}

function pagination(req) {
    let limit, page, offset
    let query = req.query
    let name = query.name || ''
    let sex = query.sex || []
    limit = Math.abs(Number(query.limit)) || null
    page = Math.abs(Number(query.page)) || 1
    offset = (page - 1) * limit
    return { limit, page, offset }
}
module.exports = {
    success,
    fail,
    pagination
}